VIMS::Application.routes.draw do
  
  resources :tipos_vehiculos
  get "salidas_almacen/buscar_rts" => "salidas_almacen#busqueda_rts", :as => "busqueda_rts"
  post "salidas_almacen/buscar_rts" => "salidas_almacen#buscar_rts", :as => "buscar_rts"
  delete "salidas_almacen/salida_items/:id/eliminar" => "salidas_almacen#eliminar_detalle_rt_salida", :as => "eliminar_detalle_rt_salida"
  get "salidas_almacen/:id/salida_items" => "salidas_almacen#salida_items", :as => "salida_items"
  post "salidas_almacen/:id/salidas_items" => "salidas_almacen#guardar_salida_items", :as =>"guardar_salida_items"
  get "salidas_almacen/rt/:receiving_ticket_id/new" => "salidas_almacen#new", :as =>"new_salida_almacen"
#
  post "salidas_almacen/rt/:receiving_ticket_id/new" => "salidas_almacen#create"
  put "salidas_almacen/rt/:receiving_ticket_id/edit" => "salidas_almacen#update"
  resources :salidas_almacen

  resources :det_ordenes_compra

#  get ":idOrden/det_ordenes_compra" => "det_ordenes_compra#index", :as => "det_ordenes_compra"
#  get "orden/:idOrden/det_orden_compra/:idDet" => "det_ordenes_compra#show", :as => "mostrar_det_orden_compra"
#  post ":idOrden/det_ordenes_compra" => "det_ordenes_compra#create", :as => "det_ordenes_compra"
#  get "orden/:idOrden/det_ordenes_compra/:idDet" => "det_ordenes_compra#edit", :as => "editar_det_orden_compra"
#  
  post "agregar_det_orden" => "ordenes_compra#agregar_det_orden", :as => "agregar_det_orden"
  delete "det_orden_compra/:id/:no_detalle" => "ordenes_compra#eliminar_det_orden", :as =>"eliminar_det_orden"
  delete "det_orden_compra_temp/:no_detalle" => "ordenes_compra#eliminar_det_orden_temp", :as =>"eliminar_det_orden_temp"
#  get "ordenes_compra/:id/detalle" => "ordenes_compra#oc_detalle", :as => "oc_detalle"
#  post "ordenes_compra/:id/detalle/guardar_campos" => "ordenes_compra#guardar_detalle_oc" , :as => "guardar_detalle_oc"
  resources :ordenes_compra

  resources :destinos

  resources :items

  get "receiving_tickets/detalle/:id_detalle" => "receiving_tickets#get_detalle_rt", :as => "get_detalle_rt"
  match "receiving_tickets/detalle_rt/:id" => "receiving_tickets#eliminar_detalle_rt", :as => "eliminar_detalle_rt", :via => [:get,:delete]
  get "receiving_tickets/:id/detalle_rt" => "receiving_tickets#detalle_rt", :as => "detalle_rt"
  post "receiving_tickets/:id/detalle_rt" => "receiving_tickets#guardar_detalle_rt", :as => "guardar_detalle_rt"
  post "receiving_tickets/cliente_rt/:accion" => "receiving_tickets#cliente_rt", :as => "cliente_rt"
  get "receiving_tickets/seleccionar_cliente/:accion" => "receiving_tickets#seleccionar_cliente" ,  :as => "seleccionar_cliente" 
  post "receiving_tickets/ordenes_rt" => "receiving_tickets#ordenes_rt", :as => "ordenes_rt"
  get "receiving_tickets/seleccionar_ordenes" => "receiving_tickets#seleccionar_ordenes" ,  :as => "seleccionar_ordenes"
  get "proveedores/agregar_proveedor" => "receiving_tickets#agregar_proveedor" , :as=>"agregar_proveedor"
   resources :receiving_tickets

  resources :pantallas

  resources :usuarios

  resources :paises

  resources :unidades_medida

  resources :conceptos_cobro

  resources :transportistas

  resources :proveedores

  resources :inventario

  resources :clientes
  get '/clientes/:idCliente/asignar_transportistas' => 'clientes#asignar_transportistas', :as => "asignar_transportistas"
  post '/clientes/:idCliente/agregar_transportistas' => 'clientes#agregar_transportistas', :as => "agregar_transportistas"

  get '/clientes/:idCliente/asignar_proveedores' => 'clientes#asignar_proveedores', :as => "asignar_proveedores"
  post '/clientes/:idCliente/agregar_proveedores' => 'clientes#agregar_proveedores', :as => "agregar_proveedores"

  get '/clientes/:idCliente/asignar_items' => 'clientes#asignar_items', :as => "asignar_items"
  post '/clientes/:idCliente/agregar_items' => 'clientes#agregar_items', :as => "agregar_items"

  #Agrega TODAS las vistas del sistema a la BD (solo se debe correr UNA vez ya que al hacerlo de nuevo
  # se eliminan todas las que estaban y se vuelven a crear y se debe hacer de nuevo la configuracion del
  # nombre por cada vista)
  get "perfiles/administracion_vistas" => "perfiles#administracion_vistas" ,  :as => "admin_vistas"
  post "pantallas_sistema" => "perfiles#pantallas_sistema" , :as => "pantallas_sistema"
  
  #Se le asigna un Nombre a cada vista que es el que se le mostrara al administrador del sistema a la hora
  # de asignar permisos a un perfil
  get "perfiles/configuracion_pantallas" => "perfiles#configuracion_pantallas", :as => "config_pantallas" 
  post "perfiles/nombres_pantallas" => "perfiles#nombres_pantallas", :as => "nombres_pantallas"
  
  #Al iniciar sesion si el usuario tiene mas de un perfil debe seleccionar uno
  get "perfiles_usuario" => "perfiles#perfiles_usuario" , :as => "perfiles_usuario"
  post "perfiles/seleccion_perfil" => "perfiles#seleccion_perfil", :as => "seleccion_perfil"
  
  # Asigna permisos por pantalla a un perfil
  get "perfiles/:idPerfil/asignar_pantallas" => "perfiles#asignar_pantallas" , :as => "asignar_pantallas"
  post "perfiles/:idPerfil/pantallas_perfil" => "perfiles#pantallas_perfil" ,  :as => "pantallas_perfil"

  resources :perfiles

  resources :empleados

#  get "sessions/new"
#  get "sessions/create"
#  get "sessions/destroy"

  
  resources :sessions, :only => [:new, :create, :destroy]
  get 'login' => "sessions#new",      :as => :login
  get 'logout' => "sessions#destroy", :as => :logout

  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".
  get "inicio" => "inicio#index", :as => :inicio

  # You can have the root of your site routed with "root"
   root 'inicio#index'

  # Example of regular route:
  #   get 'products/:id' => 'catalog#view'

  # Example of named route that can be invoked with purchase_url(id: product.id)
  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

  # Example resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Example resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Example resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Example resource route with more complex sub-resources:
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', on: :collection
  #     end
  #   end

  # Example resource route with concerns:
  #   concern :toggleable do
  #     post 'toggle'
  #   end
  #   resources :posts, concerns: :toggleable
  #   resources :photos, concerns: :toggleable

  # Example resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
end
